package cool.webstudy.admin.controller.competition;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cool.webstudy.admin.model.dto.competition.CreateCompetitionDTO;
import cool.webstudy.admin.model.dto.competition.InitCompetitionForIPDTO;
import cool.webstudy.admin.model.dto.competition.PaginationQueryCompetitionInfoListDTO;
import cool.webstudy.admin.model.dto.competition.UpdateCompetitionDTO;
import cool.webstudy.admin.model.vo.competition.PaginationQueryCompetitionInfoListVO;
import cool.webstudy.admin.model.vo.competition.QueryCompetitionDetailInfoVO;
import cool.webstudy.admin.model.vo.competition.QueryCompetitionRoughInfoVO;
import cool.webstudy.admin.model.vo.team.QueryTeamRoughInfoVO;
import cool.webstudy.admin.service.CompetitionService;
import cool.webstudy.admin.utils.aspect.logger.operation.ApiOperationLog;
import cool.webstudy.admin.utils.aspect.request.RequestParameterCheck;
import cool.webstudy.admin.utils.common.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "赛事管理")
@RestController
@RequestMapping("/competition")
@RequestParameterCheck
public class CompetitionController {
    @Autowired
    private CompetitionService competitionService;

    @PostMapping("/create")
    @Operation(summary = "创建赛事接口")
    @ApiOperationLog(description = "创建赛事接口")
    public Result create(@RequestBody CreateCompetitionDTO createCompetitionDTO) {
        competitionService.createCompetition(createCompetitionDTO);
        return Result.success();
    }
    @PostMapping("/update")
    @Operation(summary = "编辑赛事接口")
    @ApiOperationLog(description = "编辑赛事接口")
    public Result update(@RequestBody UpdateCompetitionDTO updateCompetitionDTO) {
        competitionService.updateCompetition(updateCompetitionDTO);
        return Result.success();
    }
    @PostMapping("/init/for/ip")
    @Operation(summary = "根据IP地址初始化赛事")
    @ApiOperationLog(description = "根据IP地址初始化赛事")
    public Result initForIP(@RequestBody InitCompetitionForIPDTO initCompetitionForIPDTO) {
        competitionService.initForIP(initCompetitionForIPDTO);
        return Result.success();
    }
    @PostMapping("/page-query/list")
    @Operation(summary = "分页查询赛事信息列表接口")
    public Result<Page<PaginationQueryCompetitionInfoListVO>> paginationQueryList(@RequestBody PaginationQueryCompetitionInfoListDTO dto){
        Page<PaginationQueryCompetitionInfoListVO> vo = competitionService.paginationQueryCompetitionInfoList(dto);
        return Result.success(vo);
    }
    @GetMapping("/query/rough-info/list")
    @Operation(summary = "获取赛事基本信息列表接口")
    public Result<List<QueryCompetitionRoughInfoVO>> queryRoughInfoList() {
        List<QueryCompetitionRoughInfoVO> vo = competitionService.queryCompetitionRoughInfoList();
        return Result.success(vo);
    }
    @GetMapping("/query/detail-info")
    @Operation(summary = "获取赛事详细信息接口")
    public Result<QueryCompetitionDetailInfoVO> queryDetailInfo(@RequestParam String unCode) {
        QueryCompetitionDetailInfoVO vo = competitionService.queryCompetitionDetailInfoVO(unCode);
        return Result.success(vo);
    }
}
